<?php
class Admin_Model_DbTable_LibraryPhoto extends Zend_Db_Table_Abstract {
	protected $_name = 'lib_photo';
	public function addLibPhoto($lib_name, $dateon, $dateoff, $description,$img, $status) {
		$data = array (
				'NAME' => $lib_name,
				'DATEON' => $dateon,
				'DESCRIPTION' => $description,
				'DATEOFF' => $dateoff,
				"IMG"=>$img,
				'STATUS' => $status 
		);
		return $this->insert ( $data );
	}
	public function updateLibPhoto($id, $lib_name, $dateon, $dateoff, $description,$img, $status) {
		$data = array (
				'NAME' => $lib_name,
				'DATEON' => $dateon,
				'DESCRIPTION' => $description,
				'DATEOFF' => $dateoff,
				"IMG"=>$img,
				'STATUS' => $status 
		);
		return $this->update ( $data, "ID = $id" );
	}
	public function updateStatus($id, $status) {
		$data = array (
				'STATUS' => $status 
		);
		return $this->update ( $data, "ID = $id" );
	}
	public function removeLibPhoto($id) {
		return $this->delete ( "ID = $id" );
	}
	public function getAllLibPhoto() {
		return $this->fetchAll ("STATUS = 1","ID DESC")->toArray ();
	}
	// trong lib photo lam gi co truong Name ?
	public function getLibPhotoByName($lib_name, $status) {
		
	}
	public function getLibPhotoByStatus($status) {
		return $this->fetchAll("STATUS = $status","ID DESC")->toArray();
	}
	public function getLibPhotoById($id, $status) {
		return $this->fetchRow("ID = $id")->toArray();
	}
	public function ShowLibPhoto(){
		return $this->fetchAll ( "STATUS = 1" )->toArray ();
	}
	public function active($id){
		$lp = $this->fetchRow("ID = $id");
		if($lp->STATUS == 1){
			$this->update(array("STATUS"=>0), "ID = $id");
		}else{
			$this->update(array("STATUS"=>1), "ID = $id");
		}
	}
}

